import {View, Button, Text, Image, WebView} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, {Component} from 'react';
import * as T from '../types';
import './order.less';
import actions from '../actions/index';
import {connect} from 'react-redux';
import {store2Props} from '../selectors';
import 'taro-ui/dist/style/components/icon.scss';
import houseOrderIcon from '@/assets/image/my/houseOrder.png';
import shopOrderIcon from '@/assets/image/my/shopOrder.png';
import ryutil from '../../../libs/ryutil';

type IOrderProps = T.IProps & T.IOrderProps;
//@ts-ignore
@connect<Partial<IOrderProps>, T.IOrderState>(store2Props, actions)
export default class Info extends Component<Partial<IOrderProps>, T.IOrderState> {
  constructor(props: IOrderProps) {
    super(props);
    this.state = {
      channel: 'rykj',
      secret: '9a5cf90547b3475b961f6f136f97659e',
      sign: '',
      phone: '',
      url: '',
      isShow: false,
    };
  }

  componentDidMount() {
    // let { channel, secret, phone, sign } = this.state;
    // let userInfos = Taro.getStorageSync('b2b-wechat@login').user || {};
    // let tel = userInfos.phone;
    // let sign1 = ryutil.encrypt('channel=' + channel + '&phone=' + tel + '&secret=' + secret);
    // this.setState({
    //   url: 'https://www.daoway.cn/h5/allorder.html?channel=rykj',
    //   // url: 'https://www.daoway.cn/h5/allorder.html?channel=' + channel + '&phone=' + tel + '&sign=' + sign + '&nav=0&banner=0'
    // });
  }

  render() {
    const {main} = this.props;
    const {isLogin} = main;
    let {url, isShow} = this.state;
    return (
      <View className="PageUserCenterOrder">
        <View className="orderBox">
          <View
            className="f1"
            style={{paddingRight: '15rpx'}}
            onClick={() => {
              if (isLogin) {
                Taro.navigateTo({
                  url: '/pages/package-C/order/order-list/index',
                });
              } else {
                Taro.navigateTo({
                  url: '/pages/package-C/login/login/index',
                });
              }
            }}
          >
            <View className="item">
              <Image className="imgIcon" src={shopOrderIcon} mode="heightFix" />
              <Text className="title">商城订单</Text>
            </View>
          </View>

          <View
            className="f1"
            style={{paddingLeft: '15rpx'}}
            onClick={() => {
              if (isLogin) {
                Taro.navigateTo({
                  url: '/pages/package-D/orderRamp/index', //权益订单聚合页
                });
              } else {
                Taro.navigateTo({
                  url: '/pages/package-C/login/login/index',
                });
              }
            }}
          >
            <View className="item">
              <Image className="imgIcon" src={houseOrderIcon} mode="heightFix" />
              <Text className="title">权益订单</Text>
            </View>
          </View>
        </View>
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
